package com.jinkaimen.goodcash.ui.holder;

import android.widget.TextView;

import com.ht.baselibs.ui.base.BaseViewHolder;
import com.ht.baselibs.utils.DateUtils;
import com.jinkaimen.goodcash.R;
import com.jinkaimen.goodcash.bean.TransactionHistoryItemBean;

public class TransactionHistoryViewHolder extends BaseViewHolder<TransactionHistoryItemBean> {
    private TextView mTypeView;
    private TextView mMsgView;
    private TextView mDateView;
    private TextView mStatusView;

    public TransactionHistoryViewHolder() {
        super(R.layout.list_transaction_history_item);
    }

    @Override
    protected void initView() {
        mTypeView = findViewById(R.id.tv_list_transaction_history_item_type);
        mMsgView = findViewById(R.id.tv_list_transaction_history_item_msg);
        mDateView = findViewById(R.id.tv_list_transaction_history_item_date);
        mStatusView = findViewById(R.id.tv_list_transaction_history_item_status);

    }

    @Override
    protected void refreshView(TransactionHistoryItemBean transactionHistoryItemBean) {
        mMsgView.setText(transactionHistoryItemBean.msg);
        mDateView.setText(DateUtils.formatDate(transactionHistoryItemBean.time));

        if (transactionHistoryItemBean.tradeType == 1){
            mStatusView.setText("+"+transactionHistoryItemBean.amount+"元");
        } else {
            mStatusView.setText("-"+transactionHistoryItemBean.amount+"元");
        }

        if (transactionHistoryItemBean.tradeType == 1){
            mTypeView.setText("收款 - "+transactionHistoryItemBean.channel);
        } else {
            mTypeView.setText("提现 - "+transactionHistoryItemBean.channel);
        }
    }
}
